< previous page page_424 next page >

Page 424
e10a6a0a59f035e870d90cca05b85fce.gif
' Create a 3-D transformation matrix for scaling
' by scale factors Sx, Sy, and Sz.
Public Sub m3Scale(M() As Single, _
    Sx As Single, Sy As Single, Sz As Single)
Dim i As Integer

    m3Identity M()
    M(1, 1) = Sx
    M(2, 2) = Sy
    M(3, 3) = Sz
End Sub
Reflection
In two dimensions, reflection across the X or Y axis is simple. To reflect an object across an axis, you scale it using a negative scale factor. For instance, to reflect an object across the Y axis, you scale it by a factor of 1 in the X direction using a transformation matrix like this one:
e10a6a0a59f035e870d90cca05b85fce.gif
 z0444-01.gif
When you apply this matrix to the point (x, y), you get:
e10a6a0a59f035e870d90cca05b85fce.gif
 z0444-02.gif
In three dimensions, you must reflect an object across a plane instead of a line. Reflecting an object across the XY, XZ, or YZ planes is easy. Simply scale the point using 1 as one of the scale factors. For example, to reflect an object across the XY plane, use a scaling transformation matrix where Sx = 1, Sy = 1, and Sz = 1. To perform one of these simple reflections, use the appropriate transformation matrix shown in Table 13.1.
Because these reflection matrices are the same as simple scaling matrices, you do not need to write separate Visual Basic routines to initialize reflection transformations.
Table 13.1 Reflection Transformation Matrices
ACROSS THE
X-Y PLANE
ACROSS THE
X-Z PLANE
ACROSS THE
Y-Z PLANE
z0444-03.gif
z0444-04.gif
z0444-05.gif

 
< previous page page_424 next page >